#/usr/bin/env python
# -*- coding: utf8 -*-
# title       :
# description :
# author      :'ShenMeng'


from multiprocessing import Pool as ProcessPool
from multiprocessing.dummy import Pool as ThreadPool


def multi_process(func, args, num=None):
    """
    多进程：cpu密集型任务
    """
    pool = ProcessPool() 
    result_list = pool.map(func, args)
    pool.close() 
    pool.join() 
    return result_list
    
def multi_thread(func, args, num=None):
    """
    多线程：IO密集型任务
    """
    pool = ThreadPool() 
    result_list = pool.map(func, args)
    pool.close() 
    pool.join() 
    return result_list